//
//  CollectView.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/5.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "CollectView.h"
#import <Masonry.h>
@implementation CollectView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupViews];
    }
    return self;
}

-(void)setupViews{
    self.topView = [[UIView alloc] init];
    [self addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(100);
    }];
    
    self.moneyLab = [[UILabel alloc] init];
    self.moneyLab.text = @"收款金额";
    self.moneyLab.textColor = [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1];
    self.moneyLab.font = [UIFont systemFontOfSize:16];
    [self.topView addSubview:self.moneyLab];
    [self.moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(10);
    }];
    
    self.symbolLab = [[UILabel alloc] init];
    self.symbolLab.text = @"￥";
    self.symbolLab.textColor = [UIColor blackColor];
    self.symbolLab.font = [UIFont systemFontOfSize:48];
    [self.topView addSubview:self.symbolLab];
    [self.symbolLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.equalTo(self.moneyLab.mas_bottom).offset(10);
    }];
    
    self.visableLab = [[UILabel alloc] init];
    self.visableLab.text = @"0.00";
    self.visableLab.textColor = [UIColor blackColor];
    self.visableLab.font = [UIFont systemFontOfSize:48];
    [self.topView addSubview:self.visableLab];
    [self.visableLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.symbolLab.mas_right);
        make.top.equalTo(self.moneyLab.mas_bottom).offset(10);
    }];
    
    self.topLineView = [[UIView alloc] init];
    self.topLineView.backgroundColor = [UIColor colorWithRed:229 / 255.0 green:229 / 255.0 blue:229 / 255.0 alpha:1];
    [self.topView addSubview:self.topLineView];
    [self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.top.equalTo(self.topView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    
    
    self.midView = [[UIView alloc] init];
    [self addSubview:self.midView];
    [self.midView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(self.topLineView);
        make.height.equalTo(self).multipliedBy(0.2);
    }];
    
    self.collectCardLab = [[UILabel alloc] init];
    self.collectCardLab.text = @"收款卡";
    self.collectCardLab.textColor = [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1];
    self.collectCardLab.font = [UIFont systemFontOfSize:14];
    [self.midView addSubview:self.collectCardLab];
    [self.collectCardLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.moneyLab);
    }];
    
    self.collectCardBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.collectCardBtn setImage:[UIImage imageNamed:@"icon_question"] forState:(UIControlStateNormal)];
    [self.midView addSubview:self.collectCardBtn];
    [self.collectCardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.collectCardLab.mas_right);
        make.centerY.equalTo(self.collectCardLab);
    }];
    
    self.accountStyleLab = [[UILabel alloc] init];
    self.accountStyleLab.text = @"到账方式";
    self.accountStyleLab.textColor = [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1];
    self.accountStyleLab.font = [UIFont systemFontOfSize:14];
    [self.midView addSubview:self.accountStyleLab];
    [self.accountStyleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.moneyLab);
    }];
    
    self.selectIndustryLab = [[UILabel alloc] init];
    self.selectIndustryLab.text = @"优选行业";
    self.selectIndustryLab.textColor = [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1];
    self.selectIndustryLab.font = [UIFont systemFontOfSize:14];
    [self.midView addSubview:self.selectIndustryLab];
    [self.selectIndustryLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.moneyLab);
    }];
    
    
    self.midLineView = [[UIView alloc] init];
    self.midLineView.backgroundColor = [UIColor colorWithRed:229 / 255.0 green:229 / 255.0 blue:229 / 255.0 alpha:1];
    [self.midView addSubview:self.midLineView];
    [self.midLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.top.equalTo(self.midView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    
    
    NSMutableArray *tipsArray = [NSMutableArray array];
    [tipsArray addObject:self.collectCardLab];
    [tipsArray addObject:self.accountStyleLab];
    [tipsArray addObject:self.selectIndustryLab];
    
    [tipsArray mas_distributeViewsAlongAxis:(MASAxisTypeVertical) withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
    
    
    self.collectCardValueLab = [[UILabel alloc] init];
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"中国工商银行(尾号0809)"];
    [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, 14)];
    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f] range:NSMakeRange(0, 6)];
    

    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153.0f/255.0f green:153.0f/255.0f blue:153.0f/255.0f alpha:1.0f] range:NSMakeRange(6, 8)];
    self.collectCardValueLab.attributedText = attributedString;
    [self.midView addSubview:self.collectCardValueLab];
    [self.collectCardValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.equalTo(self.collectCardLab);
    }];
    
    self.accountStyleValueLab = [[UILabel alloc] init];
    self.accountStyleValueLab.text = @"立即到账";
    self.accountStyleValueLab.textColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:1];
    self.accountStyleValueLab.font = [UIFont systemFontOfSize:14];
    [self.midView addSubview:self.accountStyleValueLab];
    [self.accountStyleValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.equalTo(self.accountStyleLab);
    }];
    
    
    self.selectIndustryBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.selectIndustryBtn setImage:[UIImage imageNamed:@"icon_arrow_right"] forState:(UIControlStateNormal)];
    [self.midView addSubview:self.selectIndustryBtn];
    [self.selectIndustryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.accountStyleValueLab.mas_right);
        make.centerY.equalTo(self.selectIndustryLab);
        make.width.mas_equalTo(16);
        make.height.mas_equalTo(16);
    }];
    
    
    self.selectIndustryValueLab = [[UILabel alloc] init];
    self.selectIndustryValueLab.textColor = [UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f];
    self.selectIndustryValueLab.text = @"智能推荐";
    self.selectIndustryValueLab.font = [UIFont systemFontOfSize:14];
    [self.midView addSubview:self.selectIndustryValueLab];
    [self.selectIndustryValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.selectIndustryBtn.mas_left);
        make.centerY.equalTo(self.selectIndustryLab);
    }];
    
    
    
    /*
    self.backgroundView = [[UIView alloc] init];
    self.backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
    [self addSubview:self.backgroundView];
    [self.backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo([[UIScreen mainScreen]bounds].size.height);
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
    }];
    
    
    self.arrowImv = [[UIImageView alloc] init];
    self.arrowImv.image = [UIImage imageNamed:@"more_icon_arrow"];
    [self.backgroundView addSubview:self.arrowImv];
    [self.arrowImv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.collectCardBtn);
        make.top.equalTo(self.collectCardBtn.mas_bottom).offset(3 + 64);
    }];
    
    self.popCollectCardView = [[UIView alloc] init];
    self.popCollectCardView.layer.cornerRadius = 8;
    self.popCollectCardView.backgroundColor = [UIColor whiteColor];
    [self.backgroundView addSubview:self.popCollectCardView];
    [self.popCollectCardView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.collectCardLab.mas_right).offset(-5);
        make.top.equalTo(self.arrowImv.mas_bottom);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(140);
    }];
     */
}

@end
